﻿using System.Xml;
using System.Xml.Linq;

namespace XEnamel
{
	public static class XElementExtensions
	{
		public static XmlNodeType PropertyType(this XElement @this, string propertyName)
		{
			if (@this.Attribute(propertyName) != null)
			{
				return XmlNodeType.Attribute;
			}
			else if (@this.Element(string.Format("{0}.{1}", @this.Name, propertyName)) != null)
			{
				return XmlNodeType.Element;
			}
			return XmlNodeType.None;
		}

		public static bool HasProperty(this XElement @this, string propertyName)
		{
			return @this.PropertyType(propertyName) != XmlNodeType.None;
		}
	}
}